package com.recipeexchange.domain

import com.recipeexchange.RecipeType
import com.recipeexchange.utils.GenerateLocator
import org.grails.comments.Commentable

class Recipe implements Commentable{
    String name
    String serves
    String locator
    String description
    String recipe
    String ingredients
    RecipeType recipeType
    long views = 0

    static belongsTo = [user:User]

    static constraints = {
        locator blank:true, nullable:true
        name blank:false, nullable:false
    }

    def beforeInsert(){
        locator = GenerateLocator.generate(name)
    }
}